/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.account.core.repository.mapper;

import info.peigen.hotpot.business.account.core.repository.entity.AccountEntity;
import info.peigen.hotpot.business.router.facade.enums.ChannelCode;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

/**
 * <b>(AccountMapper)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/12
 */
@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
public interface AccountMapper extends AbstractBeetlSqlMapper<AccountEntity> {
    @Sql("select * from account where account_id = ?")
    @Select
    AccountEntity findByAccountId(String accountId);

    @Sql("select * from account where account_id = ? for update")
    @Select
    AccountEntity lockByAccountId(String accountId);

    @Sql("select * from account where customer_id = ?")
    @Select
    AccountEntity findByCustomerId(String customerId);

    @Sql("select * from account where account_type='Provisions' and channel_code = ?")
    @Select
    AccountEntity findProvisionsAccountByCode(ChannelCode code);

    @Sql("select * from account where account_type='Provisions' and channel_code = ? for update")
    @Select
    AccountEntity lockProvisionsAccountByCode(ChannelCode code);

    @Sql("select * from account where account_type='Fee'")
    @Select
    AccountEntity findFeeAccount();

    @Sql("delete from account where account_id = ?")
    @Update
    void deleteByAccountId(String accountId);

    @Sql("delete from account where account_type='Provisions' and channel_code = ?")
    @Update
    void deleteProvisionsAccountByCurrencyAndCode(ChannelCode code);

    @Sql("delete from account where customer_id = ?")
    @Update
    void deleteByCustomerId(String customerId);

    @Sql("delete from account where partner_id = ?")
    @Update
    void deleteByPartnerId(String partnerId);

    @Sql("delete from account where alias_name = ?")
    @Update
    void deleteByAliasName(String aliasName);
}